package com.design.command.logger;

// 命令接口
interface Command {
    void execute();
}

// 插入文本命令
class InsertTextCommand implements Command {
    private TextEditor textEditor;
    private String text;

    public InsertTextCommand(TextEditor textEditor, String text) {
        this.textEditor = textEditor;
        this.text = text;
    }

    @Override
    public void execute() {
        textEditor.insertText(text);
    }
}

// 删除文本命令
class DeleteTextCommand implements Command {
    private TextEditor textEditor;
    private String text;

    public DeleteTextCommand(TextEditor textEditor, String text) {
        this.textEditor = textEditor;
        this.text = text;
    }

    @Override
    public void execute() {
        textEditor.deleteText(text);
    }
}
